<?php

namespace App\Http\Controllers\Mobile;

use App\Models\Item;

class ItemController extends BaseController
{
    public function index()
    {

    }

    public function detail($itemid)
    {
        $item = Item::find($itemid);
        if ($item) {
            $item->incrementViews();
            if ($item->on_sale) {
                $catlog  = $item->catlog;
                $content = $item->content;
                $images  = $item->images;
                $shop = $item->shop;

                $this->assign(compact('itemid', 'item', 'catlog', 'content', 'images', 'shop'));
                return $this->view('mobile.item.detail');
            } else {
                return $this->view('mobile.item.offsale');
            }
        } else {
            return $this->view('mobile.item.offsale');
        }
    }
}
